{% comment %}
This file reads the 'fields' variable as a list of Field objects (defined
in form_util.py) and expands them out into formatted entries.

See form_util.py for medieval details on how parameters are expanded out.
{% endcomment %}

{% for field in fields %}
   <p>{% if field.error %}
        <font color="red">
      {% endif %}
      {{ field.text|escape }}
      {% if field.required %}*{% endif %}
      {% if field.error %}
        {% if field.error_message %}
        - {{ field.error_message }}
        </font>
        {% endif %}
      {% endif %}
      <br>
      {% if field.help_text %}
        <font color="dimgray">{{ field.help_text|escape }}</font><br>
      {% endif %}
      {% ifequal field.type 'textarea'%}
        <textarea name="{{ field.name }}"
          {% if field.value %}
            value="{{ field.value|escape }}"
          {% endif %}
          {% if field.extra_params %}
            {% for param in field.extra_params %}
              {{ param }}
            {% endfor %}
          {% endif %}
        ></textarea>
      {% else %}{% ifequal field.type 'radio'%}
        {% for value in field.value_choices %}
           <input type="radio" name="{{ field.name }}" value="{{ value }}"
           {% ifequal value field.value %}
             checked
           {% endifequal %}
           >{{ value }}<br>
        {% endfor %}
      {% else %}{% ifequal field.type 'select'%}
        <select name="{{ field.name }}">
        {% for value in field.value_choices %}
           <option value="{{ value }}"
           {% ifequal value field.value %}
             selected
           {% endifequal %}
           >{{ value }}</option>
        {% endfor %}
        </select>
      {% else %}
        <input type="{{ field.type }}" name="{{ field.name }}"
          {% if field.value %}
            value="{{ field.value|escape }}"
          {% endif %}
          {% if field.extra_params %}
            {% for param in field.extra_params %}
              {{ param }}
            {% endfor %}
          {% endif %}
        />
      </p>
    {% endifequal %}{% endifequal %}{% endifequal %}
{% endfor %}
